package com.junittest.code;
package java.lang.*;

public class Vector {
	
	private float x,y,z;
	
	public Vector()
	{
		this.x = 0.0f;
		this.y = 0.0f;
		this.z = 0.0f;
	}

	public Vector(float x, float y, float z) 
	{
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	public float dotProduct(Vector v1, Vector v2)
	{
		return (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z);
	}
	
	public float crossProduct(Vector v1, Vector v2)
	{
		Vector v = new Vector();
		v.x = v1.y*v2.z - v1.z*v2.y;// aybz - azby
		v.y = v1.z*v2.x - v1.x*v2.z; //azbx - axbz
		v.z = v1.x*v2.y - v1.y*v2.x; //axby - aybx
		return v;
	}

	public Vector normalize(Vector v1)
	{
		v = clone(v1);
		l = length(v);
		v.x = v.x / l;
		v.y = v.y / l;
		v.z = v.z / l;
		return v;
	}

	public float length(Vector v1)
	{
		return sqrt(pow(v1.x,2)+pow(v1.y,2)+pow(v1.z,2));
	}

	public Vector clone(Vector v1)
	{
		Vector clone = new Vector(v1.x, v1.y, v1.z);
		return clone;
	}
}
